<template>
  <div class="empty-state">
    <div class="empty-content">
      <div class="empty-icon-wrapper">
        <div class="icon-bg">
          <i :class="icon"></i>
        </div>
        <div class="empty-dots">
          <span></span>
          <span></span>
          <span></span>
        </div>
      </div>
      <div class="empty-text">
        <h3 class="empty-title">{{ title }}</h3>
        <p class="empty-desc">{{ description }}</p>
      </div>
      <div class="empty-tips" v-if="tips && tips.length">
        <div class="tips-title">
          <i class="el-icon-info"></i>
          <span>建议您：</span>
        </div>
        <ul class="tips-list">
          <li v-for="(tip, index) in tips" :key="index">
            <i class="el-icon-check"></i>
            <span>{{ tip }}</span>
          </li>
        </ul>
      </div>
      <div class="empty-actions">
        <button class="action-btn primary" @click="onBackClick" v-if="home">
          <i class="el-icon-back"></i>
          <span>返回首页</span>
        </button>
        <button class="action-btn secondary" @click="onRefreshClick" v-if="flushed">
          <i class="el-icon-refresh"></i>
          <span>刷新数据</span>
        </button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'EmptyState',
  props: {
    title: {
      type: String,
      default: '暂无相关内容'
    },
    description: {
      type: String,
      default: '抱歉，没有找到与您选择的分类相关的内容。'
    },
    icon: {
      type: String,
      default: 'el-icon-search'
    },
    tips: {
      type: Array,
      default: () => []
    },
    onBackClick: {
      type: Function,
      default: () => {}
    },
    onRefreshClick: {
      type: Function,
      default: () => {}
    },
    home:{
      type: Boolean,
      default: true
    },
    flushed:{
      type: Boolean,
      default: true
    }
  }
}
</script>

<style scoped>
.empty-state {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 24px;
  min-height: 500px;
}

.empty-content {
  max-width: 480px;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-icon-wrapper {
  position: relative;
  display: inline-block;
  margin-bottom: 32px;
}

.icon-bg {
  width: 96px;
  height: 96px;
  background: linear-gradient(135deg,
    var(--hover-color) 0%,
    var(--card-bg) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(var(--primary-color-rgb), 0.1);
  position: relative;
  transition: all 0.3s ease;
}

.icon-bg:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 28px rgba(var(--primary-color-rgb), 0.15);
}

.icon-bg i {
  font-size: 48px;
  color: var(--primary-color);
  opacity: 0.9;
}

.empty-dots {
  position: absolute;
  bottom: 0;
  right: -12px;
  display: flex;
  gap: 4px;
}

.empty-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary-color);
  border-radius: 50%;
  opacity: 0.6;
  animation: dotPulse 1.4s infinite;
}

.empty-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.empty-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dotPulse {
  0%, 100% {
    transform: scale(0.8);
    opacity: 0.4;
  }
  50% {
    transform: scale(1);
    opacity: 0.8;
  }
}

.empty-text {
  margin-bottom: 32px;
}

.empty-title {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 12px;
  line-height: 1.4;
}

.empty-desc {
  font-size: 16px;
  color: var(--secondary-color);
  line-height: 1.6;
  margin: 0 auto;
  max-width: 400px;
}

.empty-tips {
  background: var(--bg-color);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 32px;
  text-align: left;
  border: 1px solid var(--border-color);
}

.tips-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-color);
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 16px;
}

.tips-title i {
  color: var(--primary-color);
  font-size: 18px;
}

.tips-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tips-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--secondary-color);
  font-size: 14px;
  margin-bottom: 12px;
  line-height: 1.5;
}

.tips-list li:last-child {
  margin-bottom: 0;
}

.tips-list li i {
  color: var(--primary-color);
  font-size: 16px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 25px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  outline: none;
}

.action-btn i {
  font-size: 16px;
}

.action-btn.primary {
  background: var(--primary-color);
  color: white;
  box-shadow: 0 4px 12px rgba(var(--primary-color-rgb), 0.2);
}

.action-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(var(--primary-color-rgb), 0.3);
}

.action-btn.secondary {
  background: var(--hover-color);
  color: var(--text-color);
}

.action-btn.secondary:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

@media (max-width: 768px) {
  .empty-state {
    padding: 36px 20px;
    min-height: 400px;
  }

  .icon-bg {
    width: 80px;
    height: 80px;
  }

  .icon-bg i {
    font-size: 40px;
  }

  .empty-title {
    font-size: 24px;
  }

  .empty-desc {
    font-size: 15px;
  }

  .empty-tips {
    padding: 20px;
    border-radius: 12px;
  }

  .tips-title {
    font-size: 15px;
    margin-bottom: 12px;
  }

  .tips-list li {
    font-size: 13px;
    margin-bottom: 10px;
  }

  .action-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .empty-state {
    padding: 24px 16px;
    min-height: 350px;
  }

  .empty-content {
    max-width: 100%;
  }

  .icon-bg {
    width: 64px;
    height: 64px;
  }

  .icon-bg i {
    font-size: 32px;
  }

  .empty-title {
    font-size: 20px;
  }

  .empty-desc {
    font-size: 14px;
  }

  .empty-tips {
    padding: 16px;
  }

  .tips-title {
    font-size: 14px;
  }

  .tips-list li {
    font-size: 12px;
  }

  .empty-actions {
    flex-direction: column;
    gap: 12px;
  }

  .action-btn {
    width: 100%;
    justify-content: center;
    padding: 10px 16px;
    font-size: 13px;
  }
}
</style>
